cmake_minimum_required(VERSION 3.10)
project(BluetoothChat)

set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_GENERATOR "Ninja")


if (NOT EXISTS ${PROJECT_SOURCE_DIR}/BluetoothChat)
	file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/BluetoothChat)
endif()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/BluetoothChat)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/BluetoothChat)

# includes
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
	set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/win/include)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
	if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
		set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/mac/x64/include)
	elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64")
		set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/mac/arm64/include)
	else()
		message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
	endif()
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
	if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm")
		set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/linux/arm/include)
	elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64")
		set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/linux/arm64/include)	
	elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
		set(BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE ${PROJECT_SOURCE_DIR}/libs/simpleble/linux/x64/include)
	else()
		message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
	endif()
else()
	message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()

set(BLUETOOTH_CHAT_INCLUDE_SQLITE3 ${PROJECT_SOURCE_DIR}/libs/sqlite3)
set(BLUETOOTH_CHAT_INCLUDE_UTILS ${PROJECT_SOURCE_DIR}/utils)
# including functions
function(bluetooth_chat_include_libs)
	include_directories(
		${BLUETOOTH_CHAT_INCLUDE_SIMPLEBLE}
		${BLUETOOTH_CHAT_INCLUDE_SQLITE3}
	)
endfunction()
function(bluetooth_chat_include_utils)
	include_directories(
			${BLUETOOTH_CHAT_INCLUDE_UTILS}
	)
endfunction()

add_subdirectory("libs")
add_subdirectory("utils")
add_subdirectory("ui")

